package com.qf.rabbitmq.confirm;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;

public class ConfigBean implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback{

    private RabbitTemplate template;

    @Autowired
    public void setRabbitTemplate(RabbitTemplate template) {
        this.template = template;
        template.setConfirmCallback(this);
        template.setReturnCallback(this);
    }

    @Override
    public void confirm(CorrelationData correlationData, boolean b, String s) {

        if (b) {
            System.err.println("发送到服务器了");
        }else{
            System.err.println("没有发送到");
        }
    }

    @Override
    public void returnedMessage(Message message, int i, String s, String s1, String s2) {

        System.err.println("消息没有送到到队列");
    }
}
